/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package meteocal.business.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author luana
 */
@Entity
@Table(name = "NOTIFICATION")
@NamedQueries({
    @NamedQuery(name = "Notification.findAll", query = "SELECT n FROM Notification n"),
    @NamedQuery(name = "Notification.findByIdNotification", query = "SELECT n FROM Notification n WHERE n.idNotification = :idNotification"),
    @NamedQuery(name = "Notification.findByIdEvent", query = "SELECT n FROM Notification n WHERE n.idEvent = :idEvent"),
    @NamedQuery(name = "Notification.findByReceiver", query = "SELECT n FROM Notification n WHERE n.receiver = :receiver"),
    @NamedQuery(name = "Notification.findByType", query = "SELECT n FROM Notification n WHERE n.type = :type"),
    @NamedQuery(name = "Notification.findByReschedulingDate", query = "SELECT n FROM Notification n WHERE n.reschedulingDate = :reschedulingDate"),
    @NamedQuery(name = "Notification.findInvitationUser", query = "SELECT n FROM Notification n WHERE n.receiver = :receiver AND n.type = 1"),
    @NamedQuery(name = "Notification.deleteByIdNotification", query = "DELETE FROM Notification n WHERE n.idNotification = :idNotification"),
    @NamedQuery(name = "Notification.checkNotification", query = "SELECT n FROM Notification n WHERE n.idEvent = :idEvent AND n.receiver = :receiver AND n.type = :type"),
    @NamedQuery(name = "Notification.findCancellationUser", query = "SELECT n FROM Notification n WHERE n.receiver = :receiver AND n.type = 2"),
    @NamedQuery(name = "Notification.findModificationUser", query = "SELECT n FROM Notification n WHERE n.receiver = :receiver AND n.type = 3"),
    @NamedQuery(name = "Notification.findBadNotificationUser", query = "SELECT n FROM Notification n WHERE n.receiver = :receiver AND n.type = 4"),
    @NamedQuery(name = "Notification.findReschedulingUser", query = "SELECT n FROM Notification n WHERE n.receiver = :receiver AND n.type = 5"),
    @NamedQuery(name = "Notification.findAlreadyThere", query = "SELECT n FROM Notification n WHERE n.idEvent =:idEvent AND n.receiver = :receiver AND n.type = :type")


})

public class Notification implements Serializable {
    
    
    private static final long serialVersionUID = 1L;
    
    public static final String FIND_INVITATION_NOTIFICATION = "Notification.findInvitationUser";
    public static final String FIND_NOTIFICATION = "Notification.findByIdNotification";
    public static final String DELETE_NOTIFICATION = "Notification.deleteByIdNotification";
    public static final String CHECK_NOTIFICATION = "Notification.checkNotification";
    public static final String FIND_BY_EVENT = "Notification.findByIdEvent";
    public static final String FIND_CANCELLATION_NOTIFICATION = "Notification.findCancellationUser";
    public static final String FIND_MODIFICATION_NOTIFICATION = "Notification.findModificationUser";
    public static final String FIND_BAD_NOTIFICATION = "Notification.findBadNotificationUser";
    public static final String FIND_RESCHEDULING_NOTIFICATION = "Notification.findReschedulingUser";
    public static final String FIND_ALREADY_EXIST = "Notification.findAlreadyThere";
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_NOTIFICATION")
    private Integer idNotification;
    
    @JoinColumn(name = "ID_EVENT", referencedColumnName = "ID_EVENT")
    @ManyToOne(optional = false)
    private Event idEvent;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "RECEIVER")
    private String receiver;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "TYPE")
    private int type;
    
    @Column(name = "RESCHEDULING_DATE")
    @Temporal(TemporalType.DATE)
    private Date reschedulingDate;

    public Notification() {
    }

    public Notification(Integer idNotification) {
        this.idNotification = idNotification;
    }

    public Notification(Integer idNotification, Event idEvent, String receiver, int type) {
        this.idNotification = idNotification;
        this.idEvent = idEvent;
        this.receiver = receiver;
        this.type = type;
    }

    public Notification(Integer idNotification, Event idEvent, String receiver, int type, Date reschedulingDate) {
        this.idNotification = idNotification;
        this.idEvent = idEvent;
        this.receiver = receiver;
        this.type = type;
        this.reschedulingDate = reschedulingDate;
    }
    
    

    public Integer getIdNotification() {
        return idNotification;
    }

    public void setIdNotification(Integer idNotification) {
        this.idNotification = idNotification;
    }

    public String getReceiver() {
        return receiver;
    }

    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public Date getReschedulingDate() {
        return reschedulingDate;
    }

    public void setReschedulingDate(Date reschedulingDate) {
        this.reschedulingDate = reschedulingDate;
    }

    public Event getIdEvent() {
        return idEvent;
    }

    public void setIdEvent(Event idEvent) {
        this.idEvent = idEvent;
    }

   
}
